package edu.lingnan.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import edu.lingnan.pojo.Product;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @Entity edu.lingnan.pojo.Product
 */
@Mapper
public interface ProductMapper extends BaseMapper<Product> {

    @Select("select * from product")
    List<Product> selectAllProduct();

    @Select("select * from product where id = #{id}")
    @ResultMap("BaseResultMap")
    List<Product> selectProductById(@Param("id") Long id);


    @Select("select * from product where product_name = #{name}")
    @ResultMap("BaseResultMap")
    List<Product> selectProductByName( @Param("name") String name);

    @Select("select * from product where product_name like #{name}")
    List<Product> selectProductLikeName(String name);

    @Select("select * from product where product_type=#{type}")
    List<Product> selectProductByType(String type);

    @Select("select * from product where store_id=#{id}")
    List<Product> selectProductByStoreId(Long id);


    @Delete("delete from product where id=#{id}")
    int deleteProductById(Long id);

    int deleteProductByIds(@Param("ids") Long[] ids);

    @Update("update product set product_status=#{status} where id=#{id}")
    int updateProductStatus(@Param("id") Long id ,@Param("status") int status);


    int updateProduct(Product product);

    Long addProduct(Product product);
}




